#include <behaviortree_cpp/bt_factory.h>
#include <behaviortree_cpp/behavior_tree.h>
#include <filesystem>
#include <fstream>
#include "rclcpp/rclcpp.hpp" 
#include "SaySomething.hpp"

int main() {
    BT::BehaviorTreeFactory factory;

    // 注册你的自定义节点
    factory.registerNodeType<SaySomething>("SaySomething");

    // 加载 XML 行为树
    std::filesystem::path config = std::filesystem::current_path().append("src/behavior_tree/config/simple_tree.xml");
    
    auto tree = factory.createTreeFromFile(config);

    // 执行 tick
    tree.tickWhileRunning();

    // instead of tree.tickWhileRunning(), you can use your own loop
    // auto status = tree.tickOnce();
    // while (status == BT::NodeStatus::RUNNING)
    // {
    //     tree.sleep(std::chrono::milliseconds(100));
    //     status = tree.tickOnce();
    // }

    return 0;
}
